/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package FourShTests;

import Rout.*;
import com.sun.jna.platform.win32.WinUser;
import org.testng.annotations.*;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;

public class Shared4UNI {
    private GoBefore browser = new GoBefore(); 
    
    
    @BeforeMethod
    public void setUp() throws Exception {
        
        System.out.println("\n Run test: " + getClass().getSimpleName());
        browser.setXpFilename("/html/body/div[7]/div/div/div[2]/h1");        
        browser.setCurURL("http://www.4shared.com/photo/jIP-_j8sce/Test_file.html");
        browser.setLpurl("getsecuredfiles");
        browser.setRepDir(getClass().getSimpleName());
       
    }
       
    
@Test //UNI  
    public void UNI() throws Exception {
        GoBefore.setTrntConfig(false);
        
        
//        browser.changeDownDir();
        
        browser.setCssButton("#downloadHelperLink > div");
        browser.setClButton("helperButtonGradient");
        browser.setLinkButton("");
        browser.setXpButton("//*[@id=\"downloadHelperLink\"]/div");
        
        browser.setUp();
        
        
        //Login
        WebElement logIN = browser.getDriver().findElement(By.xpath("//div[3]/div/i"));
        browser.getDriver().switchTo().activeElement();
        logIN.click();
        browser.getDriver().switchTo().activeElement().sendKeys("denis.mittin@yandex.com", Keys.TAB, "777_miniden", Keys.TAB, Keys.TAB, Keys.ENTER, Keys.ENTER);
        Thread.sleep(3000);
//        browser.driver.switchTo().defaultContent();
        try {
            WebElement logUser = browser.getDriver().findElement(By.xpath("/html/body/div[6]/div/div[4]/div[2]/div[1]"));
        assert logUser.isDisplayed();
            System.out.println("Login success: " + logUser.getText());
    } catch (Exception e) {
            System.out.println("Login failed");
    }
       

        Thread.sleep(1000);
         browser.getDriver().navigate().refresh();
        
        //Click on Helper button -- Scrol down (Keys.PAGE_DgetClicker() click
         for (int i = 0; i < 1; i++) {
        browser.getClicker().sendKeys(Keys.PAGE_DOWN).build().perform();
         }
        
        //sleep
        Thread.sleep(3000);
        browser.testRun();
        browser.lpDetect();
        browser.verFilePresent();
        browser.verFilename();
        
    }       
    
    @AfterMethod
    public void Down() throws Exception {
        browser.getDriver().quit();
        
    }

    
}

